/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;


import java.util.Iterator;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;



/**
 *
 * @author RasJLK
 */
@Stateless
public class CustomerOrderFacade extends AbstractFacade<CustomerOrder> {

    @PersistenceContext(unitName = "CustOrederApp-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CustomerOrderFacade() {
        super(CustomerOrder.class);
    }

    public CustomerOrder getById(Long id) {
        
        
        
        List<CustomerOrder> orders = findAll();
        Iterator it = orders.iterator();
        
        
        
        CustomerOrder o = null;
        while( it.hasNext()){
            CustomerOrder e = (CustomerOrder) it.next();
            Long x = e.getId();
            if( x.compareTo(id) == 0){
                o = e;
                break;
            }
        }
        
        return o;

    }
}
